package com.edu.base.ums.collectRecord.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.base.ums.collectRecord.domain.ClsMemberCollectRecord;
import com.edu.base.ums.collectRecord.service.IClsMemberCollectRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员收藏Controller
 * 
 * @author admin
 * @date 2021-07-21
 */
@RestController
@RequestMapping("/cls/collectRecord")
public class ClsMemberCollectRecordController extends BaseController
{
    @Autowired
    private IClsMemberCollectRecordService clsMemberCollectRecordService;

    /**
     * 查询会员收藏列表
     */
    @PreAuthorize("@ss.hasPermi('api/recored:collectRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClsMemberCollectRecord clsMemberCollectRecord)
    {
        startPage();
        List<ClsMemberCollectRecord> list = clsMemberCollectRecordService.selectClsMemberCollectRecordList(clsMemberCollectRecord);
        return getDataTable(list);
    }

    /**
     * 导出会员收藏列表
     */
    @PreAuthorize("@ss.hasPermi('api/recored:collectRecord:export')")
    @Log(title = "会员收藏", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ClsMemberCollectRecord clsMemberCollectRecord)
    {
        List<ClsMemberCollectRecord> list = clsMemberCollectRecordService.selectClsMemberCollectRecordList(clsMemberCollectRecord);
        ExcelUtil<ClsMemberCollectRecord> util = new ExcelUtil<ClsMemberCollectRecord>(ClsMemberCollectRecord.class);
        return util.exportExcel(list, "collectRecord");
    }

    /**
     * 获取会员收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('api/recored:collectRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(clsMemberCollectRecordService.selectClsMemberCollectRecordById(id));
    }

    /**
     * 新增会员收藏
     */
    @PreAuthorize("@ss.hasPermi('api/recored:collectRecord:add')")
    @Log(title = "会员收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClsMemberCollectRecord clsMemberCollectRecord)
    {
        return toAjax(clsMemberCollectRecordService.insertClsMemberCollectRecord(clsMemberCollectRecord));
    }

    /**
     * 修改会员收藏
     */
    @PreAuthorize("@ss.hasPermi('api/recored:collectRecord:edit')")
    @Log(title = "会员收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClsMemberCollectRecord clsMemberCollectRecord)
    {
        return toAjax(clsMemberCollectRecordService.updateClsMemberCollectRecord(clsMemberCollectRecord));
    }

    /**
     * 删除会员收藏
     */
    @PreAuthorize("@ss.hasPermi('api/recored:collectRecord:remove')")
    @Log(title = "会员收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(clsMemberCollectRecordService.deleteClsMemberCollectRecordByIds(ids));
    }
}
